#include "Blocks/CampfireBlock.h"

namespace PocketSurvival
{
    BlockPlacementData CampfireBlock::getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult)
    {
        BlockPlacementData result;
        result.value = Terrain::MakeBlockValue(Index(), 0, 3);
        result.cellFace = raycastResult.cellFace;
        return result;
    }

    const std::vector<BoundingBox> &CampfireBlock::getCustomCollisionBoxes(int32_t value)
    {
        int32_t num = Terrain::ExtractData(value);
        if (num < GET_ARRAY_LEN(BlockConstans::campfireCollisionBoxes))
        {
            return BlockConstans::campfireCollisionBoxes[num];
        }
        return BlockConstans::zeroCollisionBoxes;
    }

    bool CampfireBlock::shouldAvoid(int32_t value)
    {
        return Terrain::ExtractData(value) > 0;
    }

    int32_t CampfireBlock::getEmittedLightAmount(int32_t value)
    {
        int32_t num = Terrain::ExtractData(value);
        if (num > 0)
        {
            return MathUtils::Min<int32_t>(8 + num / 2, 15);
        }
        return 0;
    }

    float CampfireBlock::getHeat(int32_t value)
    {
        if (Terrain::ExtractData(value) <= 0)
        {
            return 0.0f;
        }
        return Block::getHeat(value);
    }

    int32_t CampfireBlock::getIndex()
    {
        return Index();
    }
    const std::string &CampfireBlock::getBlockName()
    {
        static std::string blockName = "CampfireBlock";
        return blockName;
    }
}